'use strict'
const { cors, parsebody, tofile } = require('titbit-toolkit')

let cr = new cors({
    allow: '*',
    allowHeaders:'authorization,content-type',
    //允许提交空的referer
    allowEmptyReferer: true
})

module.exports = [
    {
        pre: true,
        middleware: cr.mid()
    },

    {
        middleware: new parsebody,//针对post，put，delete提交body数据的请求解析数据
        method: [
            'POST', 'PUT', 'DELETE'
        ]
    },

    {
        //启用toFile中间件，在上传文件的处理中可以使用面向对象风格的调用方式。
        /**
         * 参考文档
         * {@link https://gitee.com/daoio/titbit-toolkit#tofile%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6}
         */
        middleware: new tofile,
        method: [
            'POST', 'PUT'
        ]
    }
]
